package com.zbu.demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:解决private不能被不同类访问问题
 * User: 86183
 */
class Cat{
    //成员变量
    public String name;  //public修饰 name

    private int age;    //privat 修饰 age

    String color;    //默认访问修饰限定符为default
  //getter 和 setter
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
public class Test {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.name = "富贵";
        cat.setAge(2);
        cat.color = "黄色";
        System.out.println(cat.name);    //输出富贵
        System.out.println(cat.getAge());
        System.out.println(cat.color);   //输出黄色

    }


}